FlowType

PackageAxial
Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously.

Specification

Kind
Type
Members
79
Examples
0
addFinalizerAsyncSignature
addFinalizerAsync finalizer
ofExitSignature
ofExit exit
addFinalizerSignature
addFinalizer finalizer
addDisposableSignature
addDisposable resource
addAsyncDisposableSignature
addAsyncDisposable resource

Summary

NameSignatureSynopsis
Union cases
RunSynchronouslythis.RunSynchronouslyStarts the workflow and blocks until the final exit is available.
StartAsTaskthis.StartAsTaskStarts the workflow immediately and returns a task handle for its final exit.
StartAsValueTaskthis.StartAsValueTaskStarts the workflow immediately and returns a value-task handle for its final exit.
ToAsyncthis.ToAsyncBuilds a cold async that runs the workflow when it is started.
Operations
addFinalizerAsyncaddFinalizerAsync finalizerRegisters a F# async finalizer with the current runtime scope on .NET or Fable.
ofExitofExit exitCreates a flow from an execution outcome.
addFinalizeraddFinalizer finalizerRegisters an asynchronous finalizer with the current runtime scope.
addDisposableaddDisposable resourceRegisters a disposable resource with the current runtime scope.
addAsyncDisposableaddAsyncDisposable resourceRegisters an asynchronously disposable resource with the current runtime scope.
acquireReleaseacquireRelease acquire releaseAcquires a resource and registers its release with the current runtime scope.
acquireReleaseWithacquireReleaseWith acquire release useResourceAcquires a resource, uses it, and always runs the release action.
fromAsyncfromAsync operationCreates a flow from a raw async operation.
fromAsyncResultfromAsyncResult operationCreates a flow from an async operation whose Error enters the typed error channel.
attemptAsyncattemptAsync operationCreates a flow from an async operation and treats thrown exceptions as recoverable typed errors.
fromTaskfromTask factoryCreates a flow from a cancellable task factory.
fromTaskResultfromTaskResult factoryCreates a flow from a cold task factory whose Error enters the typed error channel.
attemptTaskattemptTask factoryCreates a flow from a cancellable task factory and treats thrown exceptions as recoverable typed errors.
fromValueTaskfromValueTask factoryCreates a flow from a cancellable value-task factory.
fromValueTaskResultfromValueTaskResult factoryCreates a flow from a cold value-task factory whose Error enters the typed error channel.
attemptValueTaskattemptValueTask factoryCreates a flow from a cancellable value-task factory and treats thrown exceptions as recoverable typed errors.
awaitStartedTaskawaitStartedTask startedTaskObserves a task that has already been started.
awaitStartedTaskResultawaitStartedTaskResult startedTaskObserves an already-started task whose Error enters the typed error channel.
attemptStartedTaskattemptStartedTask startedTaskObserves a task that has already been started and treats thrown exceptions as recoverable typed errors.
awaitStartedValueTaskawaitStartedValueTask startedValueTaskObserves a value task that has already been started.
awaitStartedValueTaskResultawaitStartedValueTaskResult startedValueTaskObserves an already-started value task whose Error enters the typed error channel.
attemptStartedValueTaskattemptStartedValueTask startedValueTaskObserves a value task that has already been started and treats thrown exceptions as recoverable typed errors.
okok valueCreates a successful synchronous flow.
succeedsucceed valueAlias for ok that reads well in some call sites.
valuevalue itemAlias for ok that reads well in some call sites.
errorerror failureCreates a failing synchronous flow.
failfail failureAlias for error that reads well in some call sites.
diedie exnCreates a defective flow that fails with an exception.
fromResultfromResult resultLifts a into a synchronous flow.
verifyverify policy inputCreates a flow that verifies an input with an environment-aware policy.
withFiberObserverwithFiberObserver observer flowInstalls runtime fiber-lifecycle hooks for diagnostics and telemetry.
addFiberObserveraddFiberObserver observer flowAdds runtime fiber-lifecycle hooks, composing with any observer already installed.
withFiberRegistrywithFiberRegistry registry flowTracks every fiber forked inside the flow in registry.
withAnnotationSinkwithAnnotationSink sink flowInstalls a runtime annotation sink for integration packages.
addAnnotationSinkaddAnnotationSink sink flowAdds a runtime annotation sink, composing with any sink already installed.
annotateannotate name value flowAdds a runtime annotation for the duration of the supplied flow.
traceIdtraceId traceId flowAdds the standard trace_id runtime annotation for the duration of the supplied flow.
forkfork flowStarts a flow in a new fiber without waiting for it to complete.
forkNamedforkNamed name flowStarts a flow in a new fiber carrying a diagnostic name.
forkDetachedforkDetached flowStarts a flow in a new fiber that is deliberately never awaited.
joinjoin fiberWaits for a fiber to complete and returns its successful value or typed failure.
interruptinterrupt fiberSignals a fiber to stop and waits for it to finish its cleanup.
zipParzipPar left rightCombines two flows into a tuple of their values, running them concurrently.
racerace left rightRuns two flows concurrently and returns the result of the first one to complete.
fromOptionfromOption error valueLifts an option into a synchronous flow with the supplied error.
fromValueOptionfromValueOption error valueLifts a value option into a synchronous flow with the supplied error.
orElseFloworElseFlow errorFlow resultAttaches an environment-derived error to a result that failed without one.
envenv Reads the current environment as the successful flow value.
envWithenvWith projectionProjects one value from the current environment.
mapmap mapper flowTransforms the successful value of a flow.
ignoreignore flowMaps the successful value of a synchronous flow to unit.
bindbind binder flowSequences a dependent flow after a successful value.
(>>=)flow >>= binderSequences a synchronous continuation after a successful value.
taptap binder flowRuns an effect on success and preserves the original value.
tapErrortapError binder flowRuns a synchronous side effect on failure and preserves the original error.
mapErrormapError mapper flowMaps the error value of a synchronous flow.
tracedErrortracedError trace flowAttaches diagnostic trace text to any failure cause of the flow.
mapBothmapBoth onSuccess onFailure flowMaps both the successful value and the failure cause of a synchronous flow.
foldfold onSuccess onFailure flowFolds both the successful value and the failure cause into a new flow.
catchcatch handler flowCatches exceptions raised during execution and simple defect outcomes, then maps them to a typed error.
orElseWithorElseWith fallback flowComputes a fallback flow from the typed error when the source flow fails.
orElseorElse fallback flowFalls back to another flow when the source flow fails.
zipzip left rightRuns two flows sequentially and combines their successful values into a tuple.
map2map2 mapper left rightCombines two flows with a mapping function.
applyapply flow valueApplies a flow-wrapped function to a flow-wrapped value.
map3map3 mapper left middle rightCombines three flows with a mapping function.
(<!>)mapper flowMaps the successful value of a synchronous flow.
(<*>)flow <*> valueApplies a flow-wrapped function to a flow-wrapped value.
localEnvlocalEnv mapping flowRuns a flow against an environment derived from the outer environment.
delaydelay factoryDefers flow construction until execution time.
traversetraverse mapping valuesTransforms a sequence of values into a flow and stops at the first failure.
sequencesequence flowsTransforms a sequence of flows into a flow of a sequence and stops at the first failure.
toAsynctoAsync environment flowBuilds a cold async that runs the workflow when it is started.
startTaskstartTask environment flowStarts the workflow immediately and returns a task handle for its final exit.
runrun environment flowRuns the workflow and blocks until the final exit is available.

Union cases

kind:member

RunSynchronously

this.RunSynchronously
Member
Starts the workflow and blocks until the final exit is available.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
timeoutint
cancellationTokenCancellationToken

Returns

Exit<'value, 'error>
kind:member

StartAsTask

this.StartAsTask
Member
Starts the workflow immediately and returns a task handle for its final exit.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
cancellationTokenCancellationToken

Returns

Task<Exit<'value, 'error>>
kind:member

StartAsValueTask

this.StartAsValueTask
Member
Starts the workflow immediately and returns a value-task handle for its final exit.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
cancellationTokenCancellationToken

Returns

ValueTask<Exit<'value, 'error>>
kind:member

ToAsync

this.ToAsync
Member
Builds a cold async that runs the workflow when it is started.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
cancellationTokenCancellationToken

Returns

Async<Exit<'value, 'error>>

Operations

kind:member

addFinalizerAsync

addFinalizerAsync finalizer
Member
Registers a F# async finalizer with the current runtime scope on .NET or Fable.

Parameters

NameTypeDescription
finalizerCancellationToken -> Async<unit>

Returns

Flow<'env, 'error, unit>

Verification Examples

Flow.addFinalizerAsync (fun _ -> async { resource.Close() })
kind:member

ofExit

ofExit exit
Member
Creates a flow from an execution outcome.

Parameters

NameTypeDescription
exitExit<'value, 'error>

Returns

Flow<'env, 'error, 'value>
kind:member

addFinalizer

addFinalizer finalizer
Member
Registers an asynchronous finalizer with the current runtime scope.

Parameters

NameTypeDescription
finalizerCancellationToken -> TaskThe finalizer to run when the current scope closes.

Returns

Flow<'env, 'error, unit>
kind:member

addDisposable

addDisposable resource
Member
Registers a disposable resource with the current runtime scope.

Parameters

NameTypeDescription
resourceIDisposableThe disposable resource to close when the current scope closes.

Returns

Flow<'env, 'error, unit>
kind:member

addAsyncDisposable

addAsyncDisposable resource
Member
Registers an asynchronously disposable resource with the current runtime scope.

Parameters

NameTypeDescription
resourceIAsyncDisposableThe async disposable resource to close when the current scope closes.

Returns

Flow<'env, 'error, unit>
kind:member

acquireRelease

acquireRelease acquire release
Member
Acquires a resource and registers its release with the current runtime scope.

Parameters

NameTypeDescription
acquireFlow<'env, 'error, 'resource>The flow that acquires the resource.
release'resource -> CancellationToken -> TaskThe release action to run when the current scope closes.

Returns

Flow<'env, 'error, 'resource>
kind:member

acquireReleaseWith

acquireReleaseWith acquire release useResource
Member
Acquires a resource, uses it, and always runs the release action.

Parameters

NameTypeDescription
acquireFlow<'env, 'error, 'resource>The flow that acquires the resource.
release'resource -> CancellationToken -> TaskThe release action to run after the resource is used.
useResource'resource -> Flow<'env, 'error, 'value>The flow that uses the acquired resource.

Returns

Flow<'env, 'error, 'value>
kind:member

fromAsync

fromAsync operation
Member
Creates a flow from a raw async operation.

Parameters

NameTypeDescription
operationAsync<'value>

Returns

Flow<'env, 'error, 'value>
kind:member

fromAsyncResult

fromAsyncResult operation
Member
Creates a flow from an async operation whose Error enters the typed error channel.

Parameters

NameTypeDescription
operationAsync<Result<'value, 'error>>

Returns

Flow<'env, 'error, 'value>
kind:member

attemptAsync

attemptAsync operation
Member
Creates a flow from an async operation and treats thrown exceptions as recoverable typed errors.

Parameters

NameTypeDescription
operationAsync<'value>

Returns

Flow<'env, exn, 'value>
kind:member

fromTask

fromTask factory
Member
Creates a flow from a cancellable task factory.

Parameters

NameTypeDescription
factoryCancellationToken -> Task<'value>Starts the operation, observing the supplied cancellation token.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.fromTask (fun token -> client.GetStringAsync(url, token))
kind:member

fromTaskResult

fromTaskResult factory
Member
Creates a flow from a cold task factory whose Error enters the typed error channel.

Parameters

NameTypeDescription
factoryCancellationToken -> Task<Result<'value, 'error>>

Returns

Flow<'env, 'error, 'value>
kind:member

attemptTask

attemptTask factory
Member
Creates a flow from a cancellable task factory and treats thrown exceptions as recoverable typed errors.

Parameters

NameTypeDescription
factoryCancellationToken -> Task<'value>Starts the operation, observing the supplied cancellation token.

Returns

Flow<'env, exn, 'value>
kind:member

fromValueTask

fromValueTask factory
Member
Creates a flow from a cancellable value-task factory.

Parameters

NameTypeDescription
factoryCancellationToken -> ValueTask<'value>Starts the operation, observing the supplied cancellation token.

Returns

Flow<'env, 'error, 'value>
kind:member

fromValueTaskResult

fromValueTaskResult factory
Member
Creates a flow from a cold value-task factory whose Error enters the typed error channel.

Parameters

NameTypeDescription
factoryCancellationToken -> ValueTask<Result<'value, 'error>>

Returns

Flow<'env, 'error, 'value>
kind:member

attemptValueTask

attemptValueTask factory
Member
Creates a flow from a cancellable value-task factory and treats thrown exceptions as recoverable typed errors.

Parameters

NameTypeDescription
factoryCancellationToken -> ValueTask<'value>Starts the operation, observing the supplied cancellation token.

Returns

Flow<'env, exn, 'value>
kind:member

awaitStartedTask

awaitStartedTask startedTask
Member
Observes a task that has already been started.

Parameters

NameTypeDescription
startedTaskTask<'value>A task that is already running.

Returns

Flow<'env, 'error, 'value>
kind:member

awaitStartedTaskResult

awaitStartedTaskResult startedTask
Member
Observes an already-started task whose Error enters the typed error channel.

Parameters

NameTypeDescription
startedTaskTask<Result<'value, 'error>>

Returns

Flow<'env, 'error, 'value>
kind:member

attemptStartedTask

attemptStartedTask startedTask
Member
Observes a task that has already been started and treats thrown exceptions as recoverable typed errors.

Parameters

NameTypeDescription
startedTaskTask<'value>A task that is already running.

Returns

Flow<'env, exn, 'value>
kind:member

awaitStartedValueTask

awaitStartedValueTask startedValueTask
Member
Observes a value task that has already been started.

Parameters

NameTypeDescription
startedValueTaskValueTask<'value>A value task that is already running.

Returns

Flow<'env, 'error, 'value>
kind:member

awaitStartedValueTaskResult

awaitStartedValueTaskResult startedValueTask
Member
Observes an already-started value task whose Error enters the typed error channel.

Parameters

NameTypeDescription
startedValueTaskValueTask<Result<'value, 'error>>

Returns

Flow<'env, 'error, 'value>
kind:member

attemptStartedValueTask

attemptStartedValueTask startedValueTask
Member
Observes a value task that has already been started and treats thrown exceptions as recoverable typed errors.

Parameters

NameTypeDescription
startedValueTaskValueTask<'value>A value task that is already running.

Returns

Flow<'env, exn, 'value>
kind:member

ok

ok value
Member
Creates a successful synchronous flow.

Parameters

NameTypeDescription
value'valueThe value to wrap in a successful flow.

Returns

Flow<'env, 'error, 'value>
kind:member

succeed

succeed value
Member
Alias for ok that reads well in some call sites.

Parameters

NameTypeDescription
value'valueThe value to wrap in a successful flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let result = Flow.succeed 42 |> Flow.run ()
// result = Success 42
kind:member

value

value item
Member
Alias for ok that reads well in some call sites.

Parameters

NameTypeDescription
item'valueThe value to wrap in a successful flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

Flow.value "constant" |> Flow.run ()
kind:member

error

error failure
Member
Creates a failing synchronous flow.

Parameters

NameTypeDescription
failure'errorThe error value to wrap in a failing flow.

Returns

Flow<'env, 'error, 'value>
kind:member

fail

fail failure
Member
Alias for error that reads well in some call sites.

Parameters

NameTypeDescription
failure'errorThe error value to wrap in a failing flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let result = Flow.fail "error" |> Flow.run ()
// result = Failure (Cause.Fail "error")
kind:member

die

die exn
Member
Creates a defective flow that fails with an exception.

Parameters

NameTypeDescription
exnexnThe exception representing the defect.

Returns

Flow<'env, 'error, 'value>
kind:member

fromResult

fromResult result
Member
Lifts a Result`2 into a synchronous flow.

Parameters

NameTypeDescription
resultResult<'value, 'error>The result value to lift.

Returns

Flow<'env, 'error, 'value>

Verification Examples

Flow.fromResult (Ok "success") |> Flow.run ()
kind:member

verify

verify policy input
Member
Creates a flow that verifies an input with an environment-aware policy.

Parameters

NameTypeDescription
policyPolicy<'env, 'error, 'input, 'output>The reusable verification rule to apply.
input'inputThe input value to verify.

Returns

Flow<'env, 'error, 'output>
kind:member

withFiberObserver

withFiberObserver observer flow
Member
Installs runtime fiber-lifecycle hooks for diagnostics and telemetry.

Parameters

NameTypeDescription
observerFiberObserverThe lifecycle hooks. Start from FiberObserver.none and override what you need.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>
kind:member

addFiberObserver

addFiberObserver observer flow
Member
Adds runtime fiber-lifecycle hooks, composing with any observer already installed.

Parameters

NameTypeDescription
observerFiberObserverThe lifecycle hooks to add.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>
kind:member

withFiberRegistry

withFiberRegistry registry flow
Member
Tracks every fiber forked inside the flow in registry.

Parameters

NameTypeDescription
registryFiberRegistryThe registry that receives fiber lifecycle events.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>
kind:member

withAnnotationSink

withAnnotationSink sink flow
Member
Installs a runtime annotation sink for integration packages.

Parameters

NameTypeDescription
sinkstring -> string -> unit
flowFlow<'env, 'error, 'value>

Returns

Flow<'env, 'error, 'value>
kind:member

addAnnotationSink

addAnnotationSink sink flow
Member
Adds a runtime annotation sink, composing with any sink already installed.

Parameters

NameTypeDescription
sinkstring -> string -> unit
flowFlow<'env, 'error, 'value>

Returns

Flow<'env, 'error, 'value>
kind:member

annotate

annotate name value flow
Member
Adds a runtime annotation for the duration of the supplied flow.

Parameters

NameTypeDescription
namestringThe annotation key.
valuestringThe annotation value.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>
kind:member

traceId

traceId traceId flow
Member
Adds the standard trace_id runtime annotation for the duration of the supplied flow.

Parameters

NameTypeDescription
traceIdstringThe trace identifier.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>
kind:member

fork

fork flow
Member
Starts a flow in a new fiber without waiting for it to complete.

Parameters

NameTypeDescription
flowFlow<'env, 'error, 'value>The flow to fork.

Returns

Flow<'env, 'none, Fiber<'error, 'value>>
kind:member

forkNamed

forkNamed name flow
Member
Starts a flow in a new fiber carrying a diagnostic name.

Parameters

NameTypeDescription
namestringThe diagnostic name recorded in the fiber's metadata.
flowFlow<'env, 'error, 'value>The flow to fork.

Returns

Flow<'env, 'none, Fiber<'error, 'value>>
kind:member

forkDetached

forkDetached flow
Member
Starts a flow in a new fiber that is deliberately never awaited.

Parameters

NameTypeDescription
flowFlow<'env, 'error, 'value>The flow to fork.

Returns

Flow<'env, 'none, Fiber<'error, 'value>>
kind:member

join

join fiber
Member
Waits for a fiber to complete and returns its successful value or typed failure.

Parameters

NameTypeDescription
fiberFiber<'error, 'value>The fiber to join.

Returns

Flow<'env, 'error, 'value>
kind:member

interrupt

interrupt fiber
Member
Signals a fiber to stop and waits for it to finish its cleanup.

Parameters

NameTypeDescription
fiberFiber<'error, 'value>The fiber to interrupt.

Returns

Flow<'env, 'none, Exit<'value, 'error>>
kind:member

zipPar

zipPar left right
Member
Combines two flows into a tuple of their values, running them concurrently.

Parameters

NameTypeDescription
leftFlow<'env, 'error, 'left>The first flow to combine.
rightFlow<'env, 'error, 'right>The second flow to combine.

Returns

Flow<'env, 'error, ('left * 'right)>

Verification Examples

let combined = Flow.zipPar (Flow.succeed 1) (Flow.succeed 2)
combined |> Flow.run ()
kind:member

race

race left right
Member
Runs two flows concurrently and returns the result of the first one to complete.

Parameters

NameTypeDescription
leftFlow<'env, 'error, 'value>The first flow to run.
rightFlow<'env, 'error, 'value>The second flow to run.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let fastOrSlow = Flow.race (Flow.succeed "cached") (Flow.succeed "loaded")
fastOrSlow |> Flow.run ()
kind:member

fromOption

fromOption error value
Member
Lifts an option into a synchronous flow with the supplied error.

Parameters

NameTypeDescription
error'errorThe error to return if the option is None.
value'value optionThe option to lift.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let opt = Some "value"
Flow.fromOption "missing" opt |> Flow.run ()
kind:member

fromValueOption

fromValueOption error value
Member
Lifts a value option into a synchronous flow with the supplied error.

Parameters

NameTypeDescription
error'errorThe error to return if the value option is ValueNone.
value'value voptionThe value option to lift.

Returns

Flow<'env, 'error, 'value>
kind:member

orElseFlow

orElseFlow errorFlow result
Member
Attaches an environment-derived error to a result that failed without one.

Parameters

NameTypeDescription
errorFlowFlow<'env, 'error, 'error>A flow that reads the environment to produce an error value.
resultResult<'value, unit>The pure result to bridge.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let result = Result.Error ()
let flow = Flow.orElseFlow (Flow.envWith (fun env -> "error")) result
kind:member

env

env
Member
Reads the current environment as the successful flow value.

Returns

Flow<'env, 'error, 'env>

Verification Examples

let myFlow = Flow.env |> Flow.map (fun env -> env)
kind:member

envWith

envWith projection
Member
Projects one value from the current environment.

Parameters

NameTypeDescription
projection'env -> 'valueA function that extracts a value from the environment.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let currentTime () =
    Flow.envWith (fun (environment: BaseRuntime) -> environment.Clock.UtcNow())
kind:member

map

map mapper flow
Member
Transforms the successful value of a flow.

Parameters

NameTypeDescription
mapper'value -> 'nextA function of type 'value -> 'next to transform the successful value.
flowFlow<'env, 'error, 'value>The source flow of type Axial`3 to transform.

Returns

Flow<'env, 'error, 'next>

Verification Examples

let flow = Flow.succeed 1 |> Flow.map (fun x -> x + 1)
kind:member

ignore

ignore flow
Member
Maps the successful value of a synchronous flow to unit.

Parameters

NameTypeDescription
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, unit>

Verification Examples

let flow = Flow.succeed 42 |> Flow.ignore
kind:member

bind

bind binder flow
Member
Sequences a dependent flow after a successful value.

Parameters

NameTypeDescription
binder'value -> Flow<'env, 'error, 'next>A function that takes the successful value and returns a new flow.
flowFlow<'env, 'error, 'value>The source flow to sequence.

Returns

Flow<'env, 'error, 'next>

Verification Examples

let flow = Flow.succeed 1 |> Flow.bind (fun x -> Flow.succeed (x + 1))
kind:member

(>>=)

flow >>= binder
Member
Sequences a synchronous continuation after a successful value.

Parameters

NameTypeDescription
flowFlow<'env, 'error, 'value>
binder'value -> Flow<'env, 'error, 'next>

Returns

Flow<'env, 'error, 'next>
kind:member

tap

tap binder flow
Member
Runs an effect on success and preserves the original value.

Parameters

NameTypeDescription
binder'value -> Flow<'env, 'error, unit>A function that produces a side-effect flow from the successful value.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.succeed 42 |> Flow.tap (fun x -> Flow.succeed ())
kind:member

tapError

tapError binder flow
Member
Runs a synchronous side effect on failure and preserves the original error.

Parameters

NameTypeDescription
binder'error -> Flow<'env, 'error, unit>A function that produces a side-effect flow from the error value.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.fail "error" |> Flow.tapError (fun err -> Flow.succeed ())
kind:member

mapError

mapError mapper flow
Member
Maps the error value of a synchronous flow.

Parameters

NameTypeDescription
mapper'error -> 'nextErrorThe function to transform the error value.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'nextError, 'value>

Verification Examples

let flow = Flow.fail "error" |> Flow.mapError (fun err -> err + "!")
kind:member

tracedError

tracedError trace flow
Member
Attaches diagnostic trace text to any failure cause of the flow.

Parameters

NameTypeDescription
tracestringThe diagnostic trace text, typically an operation or boundary name.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = loadUser |> Flow.tracedError "billing.load-user"
kind:member

mapBoth

mapBoth onSuccess onFailure flow
Member
Maps both the successful value and the failure cause of a synchronous flow.

Parameters

NameTypeDescription
onSuccess'value -> 'nextThe function to transform the success value.
onFailureCause<'error> -> Cause<'nextError>The function to transform the failure cause.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'nextError, 'next>
kind:member

fold

fold onSuccess onFailure flow
Member
Folds both the successful value and the failure cause into a new flow.

Parameters

NameTypeDescription
onSuccess'value -> Flow<'env, 'nextError, 'next>A function that returns a new flow from the success value.
onFailureCause<'error> -> Flow<'env, 'nextError, 'next>A function that returns a new flow from the failure cause.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'nextError, 'next>
kind:member

catch

catch handler flow
Member
Catches exceptions raised during execution and simple defect outcomes, then maps them to a typed error.

Parameters

NameTypeDescription
handlerexn -> 'errorA function of type exn -> 'error to map the exception.
flowFlow<'env, 'error, 'value>The source flow of type Axial`3 to monitor.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.die (System.Exception("boom")) |> Flow.catch (fun ex -> "caught: " + ex.Message)
kind:member

orElseWith

orElseWith fallback flow
Member
Computes a fallback flow from the typed error when the source flow fails.

Parameters

NameTypeDescription
fallback'error -> Flow<'env, 'error, 'value>A function that produces a new flow from the error value.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.fail "error" |> Flow.orElseWith (fun err -> Flow.succeed "recovered")
kind:member

orElse

orElse fallback flow
Member
Falls back to another flow when the source flow fails.

Parameters

NameTypeDescription
fallbackFlow<'env, 'error, 'value>The flow to run if the source flow fails.
flowFlow<'env, 'error, 'value>The source flow.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.fail "error" |> Flow.orElse (Flow.succeed "recovered")
kind:member

zip

zip left right
Member
Runs two flows sequentially and combines their successful values into a tuple.

Parameters

NameTypeDescription
leftFlow<'env, 'error, 'left>The first flow to run.
rightFlow<'env, 'error, 'right>The second flow to run.

Returns

Flow<'env, 'error, ('left * 'right)>

Verification Examples

Flow.zip (Flow.succeed 1) (Flow.succeed 2) |> Flow.run ()
kind:member

map2

map2 mapper left right
Member
Combines two flows with a mapping function.

Parameters

NameTypeDescription
mapper'left -> 'right -> 'valueA function that combines the successful values of both flows.
leftFlow<'env, 'error, 'left>The first flow to run.
rightFlow<'env, 'error, 'right>The second flow to run.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.map2 (fun x y -> x + y) (Flow.succeed 1) (Flow.succeed 2)
kind:member

apply

apply flow value
Member
Applies a flow-wrapped function to a flow-wrapped value.

Parameters

NameTypeDescription
flowFlow<'env, 'error, ('value -> 'next)>A flow that contains a function to apply.
valueFlow<'env, 'error, 'value>A flow that contains the value to apply the function to.

Returns

Flow<'env, 'error, 'next>

Verification Examples

let flow = Flow.apply (Flow.succeed (fun x -> x + 1)) (Flow.succeed 1)
kind:member

map3

map3 mapper left middle right
Member
Combines three flows with a mapping function.

Parameters

NameTypeDescription
mapper'left -> 'middle -> 'right -> 'valueA function that combines the successful values of all three flows.
leftFlow<'env, 'error, 'left>The first flow to run.
middleFlow<'env, 'error, 'middle>The second flow to run.
rightFlow<'env, 'error, 'right>The third flow to run.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.map3 (fun x y z -> x + y + z) (Flow.succeed 1) (Flow.succeed 2) (Flow.succeed 3)
kind:member

(<!>)

mapper <!> flow
Member
Maps the successful value of a synchronous flow.

Parameters

NameTypeDescription
mapper'value -> 'next
flowFlow<'env, 'error, 'value>

Returns

Flow<'env, 'error, 'next>
kind:member

(<*>)

flow <*> value
Member
Applies a flow-wrapped function to a flow-wrapped value.

Parameters

NameTypeDescription
flowFlow<'env, 'error, ('value -> 'next)>
valueFlow<'env, 'error, 'value>

Returns

Flow<'env, 'error, 'next>
kind:member

localEnv

localEnv mapping flow
Member
Runs a flow against an environment derived from the outer environment.

Parameters

NameTypeDescription
mapping'outerEnvironment -> 'innerEnvironmentA function that maps the outer environment to the inner environment.
flowFlow<'innerEnvironment, 'error, 'value>The flow to run with the inner environment.

Returns

Flow<'outerEnvironment, 'error, 'value>

Verification Examples

let flow = Flow.succeed 1 |> Flow.localEnv (fun outer -> outer)
kind:member

delay

delay factory
Member
Defers flow construction until execution time.

Parameters

NameTypeDescription
factoryunit -> Flow<'env, 'error, 'value>A function that returns the flow to execute.

Returns

Flow<'env, 'error, 'value>

Verification Examples

let flow = Flow.delay (fun () -> Flow.succeed 42)
kind:member

traverse

traverse mapping values
Member
Transforms a sequence of values into a flow and stops at the first failure.

Parameters

NameTypeDescription
mapping'value -> Flow<'env, 'error, 'next>A function that maps each value to a flow.
values'value seqThe sequence of values to transform.

Returns

Flow<'env, 'error, 'next list>

Verification Examples

let flows = [1; 2; 3] |> Flow.traverse (fun x -> Flow.succeed (x * 2))
kind:member

sequence

sequence flows
Member
Transforms a sequence of flows into a flow of a sequence and stops at the first failure.

Parameters

NameTypeDescription
flowsFlow<'env, 'error, 'value> seqThe sequence of flows to run.

Returns

Flow<'env, 'error, 'value list>

Verification Examples

Flow.sequence [Flow.succeed 1; Flow.succeed 2] |> Flow.run ()
kind:member

toAsync

toAsync environment flow
Member
Builds a cold async that runs the workflow when it is started.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
flowFlow<'env, 'error, 'value>The workflow to describe.

Returns

Async<Exit<'value, 'error>>

Verification Examples

let handle = workflow |> Flow.toAsync environment
kind:member

startTask

startTask environment flow
Member
Starts the workflow immediately and returns a task handle for its final exit.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
flowFlow<'env, 'error, 'value>The workflow to start.

Returns

Task<Exit<'value, 'error>>

Verification Examples

let running = workflow |> Flow.startTask environment
kind:member

run

run environment flow
Member
Runs the workflow and blocks until the final exit is available.

Parameters

NameTypeDescription
environment'envThe environment used by the workflow.
flowFlow<'env, 'error, 'value>The workflow to run.

Returns

Exit<'value, 'error>

Verification Examples

let exit = workflow |> Flow.run environment